﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

namespace OZDoo.Core
{
    public class Provider
    {
        string name;
        ExtensionType extensionType;
        string providerType;
        NameValueCollection providerAttributes = new NameValueCollection();

        public Provider(XmlAttributeCollection attributes)
        {
            name = attributes["name"].Value;
            if (attributes["extensionType"] != null)
            {
                
                try
                {
                    extensionType = (ExtensionType)Enum.Parse(typeof(ExtensionType), attributes["extensionType"].Value, true);
                }
                catch
                {
                    extensionType = ExtensionType.Unknown;
                }
            }
          
            providerType = attributes["type"].Value;
            foreach (XmlAttribute attribute in attributes)
            {
                if ((attribute.Name != "name") && (attribute.Name != "type"))
                    providerAttributes.Add(attribute.Name, attribute.Value);
            }
        }

        public string Name
        {
            get
            {
                return name;
            }
        }

        public ExtensionType ExtensionType
        {
            get { return extensionType; }
        }

        public string Type
        {
            get
            {
                return providerType;
            }
        }

        public NameValueCollection Attributes
        {
            get
            {
                return providerAttributes;
            }
        }

    }
}
